package models

import (
	"github.com/jinzhu/gorm"
	db2 "meituan/db"
)

type Category struct {
	gorm.Model
	// 名称
	Name string `form:"Name" binding:"required"`
	// ICON图标
	Icon string `form:"Icon" binding:"required"`

	Categories []Category `gorm:"foreignKey:ParentID"`

	ParentID int `form:"ParentID"`
}

func (c Category) TableName() string {
	return "category"
}

func init() {
	db, _ := db2.NewDB()
	defer db.Close()
	db.AutoMigrate(new(Category))
}
